/*
 * @Author: Clark
 * @Email: haixuanwoTxh@gmail.com
 * @Date: 2023-01-18 12:51:48
 * @LastEditors: Clark
 * @LastEditTime: 2023-01-18 12:59:03
 * @Description: file content
 */

#include "apue.h"
#include <pthread.h>

pthread_t ntid;

void printids(const char* s)
{
    pid_t   pid;
    pthread_t tid;

    pid = getpid();
    tid = pthread_self();

    printf("%s pid %lu tid %lu (0x%lx)\n", s, (unsigned long)pid, (unsigned long)tid, (unsigned long)tid);
}

void *thr_fn(void *arg)
{
    printids("new thread: ");
    return ((void *)0);
}

int main(void)
{
    int err = pthread_create(&ntid, NULL, thr_fn, NULL);
    if (0 != err)
    {
        err_exit(err, "can't create thread");
    }

    printids("main thread:");
    sleep(1);
    exit(0);
}
